﻿<!--
Copyright (c) 2010 Stephen P Ward and Joseph E Feser

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-->
    
    <UserControl x:Class="Examples.Issue5544TestControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:auto="clr-namespace:FeserWard.Controls;assembly=IntelliBox"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <StackPanel>
        <TextBlock>
            The control below binds the "SelectedItem" and "SelectedValue" properties of the Intellibox control to properties on the ViewModel.
        </TextBlock>
        <Grid
            DataContext="{Binding FirstDataContextSet}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="10" />
                <ColumnDefinition
                    Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="10" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="*" />
            </Grid.RowDefinitions>

            <Label
                Grid.Column="0"
                Grid.Row="0"
                Content="Greeting: " />
            <TextBox
                Grid.Column="2"
                Grid.Row="0"
                Text="{Binding greetingTxt}" />

            <Label
                Grid.Column="0"
                Grid.Row="1"
                Content="Full Name: " />
            <TextBox
                Grid.Column="2"
                Grid.Row="1"
                Text="{Binding nameTxt}" />

            <Label
                Grid.Column="0"
                Grid.Row="2"
                Content="Send me spam email!" />
            <CheckBox
                Grid.Column="2"
                Grid.Row="2"
                Content="this is a test checkbox"
                IsChecked="{Binding sendSpam}" />

            <Label
                Grid.Column="0"
                Grid.Row="3"
                Content="Search: " />
            <auto:Intellibox
                Grid.Column="2"
                Grid.Row="3"
                x:Name="issue5544IBox"
                DataProvider="{Binding queryResults}"
                SelectedValueBinding="{Binding Name}"
                DisplayedValueBinding="{Binding Salutation}"
                SelectedValue="{Binding valueSelected}"
                SelectedItem="{Binding itemSelected}" />

            <GroupBox
                Grid.Row="5"
                Grid.ColumnSpan="3"
                Header="selected value from the intellibox">
                <TextBox
                    Text="{Binding valueSelected}" />
            </GroupBox>

        </Grid>
        
        <TextBlock>
            The control below does NOT bind the "SelectedItem" and "SelectedValue" properties of the Intellibox control to properties on the ViewModel.
        </TextBlock>

        <Grid
            DataContext="{Binding SecondDataContextSet}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="10" />
                <ColumnDefinition
                    Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="10" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="*" />
            </Grid.RowDefinitions>

            <Label
                Grid.Column="0"
                Grid.Row="0"
                Content="Greeting: " />
            <TextBox
                Grid.Column="2"
                Grid.Row="0"
                Text="{Binding greetingTxt}" />

            <Label
                Grid.Column="0"
                Grid.Row="1"
                Content="Full Name: " />
            <TextBox
                Grid.Column="2"
                Grid.Row="1"
                Text="{Binding nameTxt}" />

            <Label
                Grid.Column="0"
                Grid.Row="2"
                Content="Send me spam email!" />
            <CheckBox
                Grid.Column="2"
                Grid.Row="2"
                Content="this is a test checkbox"
                IsChecked="{Binding sendSpam}" />

            <Label
                Grid.Column="0"
                Grid.Row="3"
                Content="Search: " />
            <auto:Intellibox
                Grid.Column="2"
                Grid.Row="3"
                x:Name="issue5544IBox2"
                DataProvider="{Binding queryResults}"
                SelectedValueBinding="{Binding Name}"
                DisplayedValueBinding="{Binding Salutation}" />

            <GroupBox
                Grid.Row="5"
                Grid.ColumnSpan="3"
                Header="selected value from the intellibox">
                <TextBox
                    Text="{Binding Path=SelectedValue, ElementName=issue5544IBox2, Mode=OneWay}" />
            </GroupBox>

            <GroupBox
                Grid.Row="6"
                Grid.ColumnSpan="3"
                Header="selected item from the intellibox">
                <TextBox
                    Text="{Binding Path=SelectedItem, ElementName=issue5544IBox2, Mode=OneWay}" />
            </GroupBox>

        </Grid>
    </StackPanel>
        
</UserControl>
